/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: 李白
 * @Created: 2024/4/26 20:06
 */
public class Test {
}
interface USB{
    void openDevice();
    void closeDevice();
}
class KeyBoard implements USB{
    public void openDevice(){
        System.out.println("打开键盘");
    }
    public void closeDevice(){
        System.out.println("关闭键盘");
    }
    public void inPut(){
        System.out.println("敲击键盘");
    }
}
class Mouse implements USB{
    @Override
    public void openDevice() {
        System.out.println("打开鼠标");
    }
    @Override
    public void closeDevice() {
        System.out.println("关闭鼠标");
    }
    public void click(){
        System.out.println("敲击鼠标");
    }
}
class Computer{
    public void powerOn(){
        System.out.println("打开电脑");
    }
    public void powerOff(){
        System.out.println("关闭电脑");
    }
    public void useDevice(USB usb){
        usb.openDevice();
        if (usb instanceof Mouse){
            Mouse mouse = (Mouse)usb;
            mouse.click();
        }else if(usb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard)usb;
            keyBoard.inPut();
        }
        usb.closeDevice();
    }
}
